<%@page import="cn.lily.com.enviroment.Enviroment"%>
<%@page import="app.portal.util.UtilMethod"%>
<%@page import="cn.lily.com.db.sql.DBManager"%>
<%@page import="app.portal.dao.Pt_app_infoBean"%>
<%@page import="app.portal.dao.Pw_app_menu_infoBean"%>
<%@page import="app.portal.util.EnumValue"%>
<%@page import="cn.lily.com.db.DBFactory"%>
<%@page import="cn.lily.com.db.container.reader.DataTable"%>
<%@page import="cn.lily.com.lang.VerifyData"%>
<%@page contentType="text/html; charset=utf-8"%>
<%@page import="cn.lily.inst.web.frames.FrameConfig"%>
<%@page import="cn.lily.web.util.context.WebContext"%>
<%@page import="cn.lily.esb.context.AuthEntity"%>
<%@page import="cn.lily.com.container.ram.ApplicationContext"%>
<%@ page import="cn.lily.com.configure.util.ESBSetting"%>
<%@page import="java.util.ArrayList"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ include file="/frames/logbegin.jsp" %>
<%
	String contextPath = "";
	AuthEntity authEntity = (AuthEntity) session.getAttribute(WebContext.LOG_AUTH_CONTEXT);
	if (authEntity != null) {
		contextPath = authEntity.getContextPath();
	}
	FrameConfig.setContextPath(contextPath);
	String flowId=request.getParameter("flowId");
	ArrayList pathArr=new ArrayList();
	ArrayList nameArr=new ArrayList();
	JSONArray pathAll = new JSONArray();
	JSONArray nameAll = new JSONArray();
	int i=0;
	DataTable table= DBFactory.getActionDB().executeQueryTable("select b.menu_src,a.node_id,a.node_nam,a.app_id"+
			" from ${schema}.pw_flow_node a left join ${schema}.pw_app_menu_info  b on a.menu_id=b.menu_id where a.flow_id = '"+flowId+"' order by a.view_idx ");
	while(table.next()){
		String url=(String)session.getAttribute(table.getString("app_id"));
		if(url==null ||"".equals(url)){
    		url=UtilMethod.getUrl(table.getString("app_id"));
    		if(!"0".equals(url)) {        
    			request.getSession().setAttribute(table.getString("app_id"), url);
    		}else {
    			System.out.print("未获取到有效的url！");
    		}
    	}
		String menu_src=table.getString("menu_src");
		String sessionID=session.getId();
		if(menu_src.indexOf("http://")<0){
			if(menu_src.indexOf("?")>0) {
				menu_src=url+menu_src+"&appid="+table.getString("app_id")+"&sessionID="+sessionID;
			}else{
				menu_src=url+menu_src+"?appid="+table.getString("app_id")+"&sessionID="+sessionID;
			} 
        }else{
        	if(menu_src.indexOf("?")>0) {
				menu_src=menu_src+"&appid="+table.getString("app_id")+"&sessionID="+sessionID;
			}else{
				menu_src=menu_src+"?appid="+table.getString("app_id")+"&sessionID="+sessionID;
			} 
        }
		pathArr.add(i,menu_src);
		nameArr.add(i,table.getString("node_nam"));
		pathAll.add(i,menu_src);
		nameAll.add(i,table.getString("node_nam"));
		i++;
	}	
%>
	<script src="<%=FrameConfig.getBaseJsUrl()%>common/jquery-1.9.1.min.js"></script>
	<script src="/<%=ESBSetting.getString("appCode")%>/public/js/skin_bootstrap/bootstrap-3.3.0/bootstrap-3.3.0.js"></script>
	<script src="<%=FrameConfig.getJsUrl("app.js")%>"></script>
	<script type="text/javascript" language="javascript">
	var path=<%=pathAll%>;
	var nodeName=<%=nameAll%>;
	$(function(){
		$(".left").click(function(){
			var x=$(".guideB").css("left");
			x=parseInt(x)-150;
			$(".guideB").animate({left:x},800);
		})
		$(".right").click(function(){
			var x=$(".guideB").css("left");
			x=parseInt(x)+150;
			$(".guideB").animate({left:x},800);
		})
		$(".show").click(function(){
  			$(".content").fadeToggle("slow","linear");
		});
		$(".node a").click(function(){
			if($(this).parent().attr("class")=="button"){
				$(".buttons").removeClass("buttons").addClass("buttone");
				$(this).parent().removeClass("button").addClass("buttons");
				$(this).parent().parent().nextAll().children(".buttone").removeClass("buttone").addClass("button");
				$(".content").fadeToggle("slow","linear");
			}else if($(this).parent().attr("class")=="buttone"){
				$(".buttons").removeClass("buttons").addClass("buttone");
				$(this).parent().removeClass("buttone").addClass("buttons");
				$(this).parent().parent().nextAll().children(".buttone").removeClass("buttone").addClass("button");
				$(".content").fadeToggle("slow","linear");
			}else if($(this).parent().attr("class")=="buttons"){
				$(this).parent().parent().nextAll().children(".buttone").removeClass("buttone").addClass("button");
				$(".content").fadeToggle("slow","linear");
			}
			var i=$(this).parent().attr("id");
			$(".next").text(nodeName[i]);
		});
		$(".next").click(function(){
			if($(".buttons").parent().next().children(".button").attr("id")!==undefined){
				var i=$(".buttons").attr("id");
				$("#"+i).removeClass("buttons").addClass("buttone");
				$("#"+i).parent().next().children(".button").removeClass("button").addClass("buttons");
				var next=parseInt(i)+1;
				$("iframe").attr({ src: path[next]});
				$(".next").text(nodeName[next]);
			}
		});
	})
	</script>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta charset=utf-8>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title><%=FrameConfig.getAppName()%></title>
	<link href="/<%=ESBSetting.getString("appCode")%>/public/style/skin_bootstrap/bootstrap-3.3.0/bootstrap.css" rel="stylesheet" media="screen">
	<link href="/<%=ESBSetting.getString("appCode")%>/public/font/awesome/font-awesome-4.7.0.css" rel="stylesheet">	
	<link href="<%=FrameConfig.getCSSPath("flowbranch.css") %>" rel="stylesheet" />
</head>
<body>
	<div class="title">
		&nbsp;&nbsp;&nbsp;流&nbsp;程&nbsp;信&nbsp;息&nbsp;
		<div class="show">首&nbsp;&nbsp;页</div>
		<div class="show">进&nbsp;&nbsp;程</div>
		<div class="next"><%=nameArr.get(0)%></div>
	</div>

	
	<div class="content">
		<a class="left"></a>
		<div class="guide">
			<div class="guideB">
				<%for(i=1;i<=pathArr.size();i++){
					if(i==1){
				%>
						<div class="node">
							<div class="name">
								<%=nameArr.get(i-1)%>
							</div>
						    <div class="buttons" id="<%=i-1%>">
						    	<a href="<%=pathArr.get(i-1)%>" target="listFrame">&nbsp;</a>
				       		</div>
				       		<div class="line">
				       			&nbsp;&nbsp;&nbsp;
				        	</div>
			    		</div>
		    		<%}else if(i==pathArr.size()){%>
			    		<div class="node">
							<div class="name">
								<%=nameArr.get(i-1)%>
							</div>
						    <div class="button" id="<%=i-1%>">
						    	<a href="<%=pathArr.get(i-1)%>" target="listFrame">&nbsp;</a>
				       		</div>
			    		</div>
		    		<%}else{%>
			    		<div class="node">
							<div class="name">
								<%=nameArr.get(i-1)%>
							</div>
						    <div class="button" id="<%=i-1%>">
						    	<a href="<%=pathArr.get(i-1)%>" target="listFrame">&nbsp;</a>
				       		</div>
				       		<div class="line">
				       			&nbsp;&nbsp;&nbsp;
				        	</div>
			    		</div>
		    		<%}
				 }%>
			</div>
		</div>
		<a class="right"></a>
	</div>
	
	<div class="list">
    	<iframe name="listFrame" src="<%=pathArr.get(0)%>"  frameborder="0" height="100%" width="100%"></iframe>
  	</div>  
</body>
</html>
<%
DBFactory.free() ;
%>
<%@ include file="/frames/logend.jsp" %>
